package com.cloud.mall.demos.sentinel;

import com.cloud.mall.exp.CustomException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author: 梁二东
 * @Date: 2024/12/12 11:24
 * @Description:
 **/
@RestController
@RequestMapping("/sentinel")
public class FlowLimitController {

    //----------限流模式：直接、关联----------
    @GetMapping("/testA")
    public String testA() {
        return "A";
    }

    @GetMapping("/testB")
    public String testB() {
        return "B";
    }

    //----------限流模式：链路----------
    @Resource
    private FlowLimitService flowLimitService;

    @GetMapping("/testC")
    public String testC() {
        flowLimitService.common();
        return "C";
    }

    @GetMapping("/testD")
    public String testD() {
        flowLimitService.common();
        return "D";
    }

    //---------------服务熔断:慢请求比例、异常比例、异常数-----------
    @GetMapping("/testE")
    public String testE() {
        int a = 1 / 0;
        return "D";
    }


}
